package cq.zhcqk.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import cq.zhcqk.R;

/**
 * Created by zhangle on 2017/11/24.
 */
public class RegisterActivity extends Activity implements View.OnClickListener{
    private Button register_next;
    private EditText register_phone;
    private ImageView header_back;
    private String sourse;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        sourse = getIntent().getStringExtra("sourse");
        initView();
        initBack();
    }
    private void initView(){
        register_next = (Button) findViewById(R.id.register_next);
        register_phone = (EditText) findViewById(R.id.register_phone);
        header_back = (ImageView) findViewById(R.id.header_back);

        register_next.setOnClickListener(this);
        header_back.setOnClickListener(this);
    }

    private void initBack(){
        ImageView back = (ImageView) findViewById(R.id.header_back);
        TextView title = (TextView) findViewById(R.id.header_text);
        if("forget".equals(sourse)){
            title.setText("修改密码");
        }else {
            title.setText("注册");
        }
        back.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()){
            case R.id.register_next:
                String phoneNo = register_phone.getText()+"";
                if ("".equals(phoneNo)){
                    Toast.makeText(this,"请输入手机号码",Toast.LENGTH_SHORT).show();
                    break;
                }
                intent = new Intent(this,Register2Activity.class);
                intent.putExtra("phone",phoneNo);
                intent.putExtra("sourse",sourse);
                startActivity(intent);
                overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
                finish();
                break;
            case R.id.header_back:
                finish();
                break;
        }
    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.slide_left_in, R.anim.slide_right_out);
    }
}